package examples;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import debugs.UserDebug;

import search.UserSearchData;
import search.UserSearchEngine;

import models.UserModel;

import entities.User;

public class ExampleServlet extends HttpServlet{
	public void doGet(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException {
		
		/*UserModel userModel = UserModel.getInstance();
		User user = new User();
		
		user.setUsername("hoantocxoan@gmail.com");
		user.setName("Bui Ngoc Hoan");
		userModel.insert(user);
		UserSearchEngine.update(user);
		
		user = new User();
		user.setUsername("hoanbn1984@gmail.com");
		user.setName("Hoan Bui Ngoc");
		userModel.insert(user);
		UserSearchEngine.update(user);
		
		user = new User();
		user.setUsername("luckystart.2678@gmail.com");
		user.setName("Dao Thi Tham");
		userModel.insert(user);
		UserSearchEngine.update(user);*/
		
		String name = "Hoan";
		String username= "luckystart.2678@gmail.com";
		response.getWriter().println();
		response.getWriter().println("Search name " + name);
		response.getWriter().println();
		ArrayList<User> users = UserSearchData.searchName(name);
		for (int i = 0; i < users.size(); i++) {
			UserDebug.debugWeb(users.get(i), response);
		}
		
		response.getWriter().println();
		response.getWriter().println("Search username " + username);
		users = UserSearchData.searchUsername(username);
		for (int i = 0; i < users.size(); i++) {
			UserDebug.debugWeb(users.get(i), response);
		}
	}
}
